package com.example.adouble.cehuamenu.ui.activity;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.example.adouble.cehuamenu.R;

/**
 * 图书馆动态
 */

public class DongTaiActivity extends AppCompatActivity {

    private WebView web;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dongtai);

        web = (WebView) findViewById(R.id.web);
        //WebView加载web资源
        web.loadUrl("http://scswjwc.net/");
        //覆盖WebView默认使用第三方或系统默认浏览器打开网页的行为，使网页用WebView打开
        web.getSettings().setSupportZoom(true);
        web.requestFocus();
        //设置是否支持JavaScript
        web.getSettings().setJavaScriptEnabled(true);
        //设置是否保存密码
        web.getSettings().setSavePassword(true);
        //自适应屏幕
        web.getSettings().setUseWideViewPort(true);
        web.getSettings().setLoadWithOverviewMode(true);
        web.getSettings().setDefaultTextEncodingName("utf-8");
        web.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {

                //返回值是true的时候控制去WebView打开，为false调用系统浏览器或第三方浏览器
                view.loadUrl(url);
                return true;
            }
        });
    }

}
